<template>
  <el-select v-model="value" filterable :placeholder="placeholder" @change="changeValue($event)" clearable style="width:100%">
    <el-option
      v-for="item in warehouses"
      :key="item.code"
      :label="item.name"
      :value="item.code"
    />
  </el-select>
</template>
<script>
  import request from '@/utils/request'
  export default {
    data() {
      return {
        value: '',
        warehouses: [],
        warehouseName: '',
      }
    },
    props: {
      placeholder: {
        type: String,
        default: "请选择所属仓库"
      },
    },

    created() {
      this.findList()
    },
    methods: {
      findList() {
        return request({
          url: '/wms/warehouse/chooseData',
          method: 'get',
          params: { warehouseName: this.warehouseName}
        }).then(response => {
          this.warehouses = response.data
        })
      },

      changeValue(val) {
        this.$emit("setWarehouseCode", val)
      },
    }
  }
</script>
